package com.study.dataStructure.set;

import java.util.HashSet;
import java.util.Set;

/**
 * @PACKAGE_NAME: com.study.dataStructure.Set
 * @CLASS_NAME: TestHashSet
 * @USER: kagura
 * @Description TODO
 * @Date 2020/12/12 12:15 上午
 * @MONTH_NAME_FULL: 十二月
 * @DAY: 12
 * @DAY_NAME_FULL: 星期六
 * @PROJECT_NAME: Study
 **/
public class TestHashSet {
    public static void main(String[] args) {
        // create a hash set
        Set<String> set = new HashSet<>();

        // add strings to the set
        set.add("重庆");
        set.add("北京");
        set.add("天津");
        set.add("上海");
        set.add("重庆");

        // display the elements in the set
        for (String s : set) {
            System.out.print(s + " ");
        }

        // process the elements using a forEach method
        System.out.println();
        set.forEach(e -> System.out.print(e + " "));
    }
}
